define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        index: function () {
            Controller.api.commsearch();
            Controller.api.bindevent();
            $(document).on('click', ".btn-detail", function () {
                var ids = $(this).attr("ids");
                var type = $(this).attr("type");
                var url = 'busrecord/detail/ids/'+ids+'/type/'+type;
                Fast.api.open(url, '预约详情',{area:['75%', '70%']});
            });
            $(document).on('click', ".btn-default", function () {
                window.location.href="";
            });
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
            commsearch: function () {
                var form = $("form.form-commonsearch");
                if ($(".datetimepicker", form).size() > 0) {
                    require(['bootstrap-datetimepicker'], function () {
                        var options = {
                            format: 'YYYY-MM-DD',   //
                            icons: {
                                time: 'fa fa-clock-o',
                                date: 'fa fa-calendar',
                                up: 'fa fa-chevron-up',
                                down: 'fa fa-chevron-down',
                                previous: 'fa fa-chevron-left',
                                next: 'fa fa-chevron-right',
                                today: 'fa fa-history',
                                clear: 'fa fa-trash',
                                close: 'fa fa-remove'
                            },
                            showTodayButton: true,
                            showClose: true
                        };
                        $('.datetimepicker', form).parent().css('position', 'relative');
                        $('.datetimepicker', form).datetimepicker(options);
                    });
                }
            }
        }
    };
    return Controller;
});